﻿using System;
using System.Collections;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            ht.Add(1, "蜜汁手枪腿");
            ht.Add(2, "脆皮手枪腿");
            ht.Add(3, "黑椒鸡块");
            ht.Add(4, "蛋挞");
            ht.Add(5, "吮指原味鸡");
            ht.Add(6, "老北京鸡肉卷");
            Console.WriteLine("请输入要购买的食物的编号");
            int id = int.Parse(Console.ReadLine());
            bool flag = ht.ContainsKey(id);
            if (flag)
            {
                Console.WriteLine("您要购买的食物为{0}",ht[id].ToString());
            }
            else
            {
                Console.WriteLine("那款食物已经售完");
            }
            Console.WriteLine("所有的食物如下：");
            foreach(DictionaryEntry a in ht)
            {
                int key = (int)a.Key;
                string value = a.Value.ToString();
                Console.WriteLine("食物编号：{0}，食物名称：{1}", key, value);
            }
        }
    }
}
